
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

	self:SetModel( "models/props/cs_militia/bottle02.mdl" )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS ) 
	self:SetColor(225,200,200,255)
	self.EmitOnce = false
	self.Die = false
	self.IsActive = false
	
	local phys = self:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
		phys:EnableDrag(true)
		phys:EnableCollisions(true)
		phys:SetMass(100)
	end
	
end

function ENT:Explode()
	if not self.Asploded then
		self.Asploded = true
		local effectdata = EffectData()
		effectdata:SetOrigin(self:GetPos())
		util.Effect("molotov_explosion", effectdata)

		self:ExplosionDamage(self:GetOwner(),self:GetPos(),30,180)
		self:FireMaker(self:GetOwner(),self:GetPos(),2,3,30)
		self:EmitSound(ChooseRandom(GameSounds.BottleHit),80,math.random(90,110))
		
		self:Remove()
	end
end

/*---------------------------------------------------------
   Name: Think
---------------------------------------------------------*/
function ENT:Think()
	if not self.Trail then
		self.Trail = true
		local effectdata = EffectData()
		effectdata:SetScale(1)
		effectdata:SetEntity(self)
		util.Effect("fire_trail", effectdata)
	end
	if self.Exploded then
		self:Explode()
	end
end 
 
 /*---------------------------------------------------------
   Name: takedamage
---------------------------------------------------------*/
function ENT:OnTakeDamage( dmginfo )
	
end

/*---------------------------------------------------------
   Name: PhysicsCollide
---------------------------------------------------------*/
function ENT:PhysicsCollide( data, physobj )
	if (data.Speed > 40 && data.DeltaTime > 0.2 ) then
		if self.Exploded then return end
		self.Exploded = true
	end
end